package com.chenyue.cm.station.service.impl;


import com.chenyue.cm.base.dao.LcBaseMapper;
import com.chenyue.cm.base.service.BaseServiceImpl;
import com.chenyue.cm.station.dao.JdStationApplyMapper;
import com.chenyue.cm.station.domain.JdStationApply;
import com.chenyue.cm.station.service.JdStationApplyService;
import com.chenyue.cm.utils.DateUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;


/**
 * @author chenyue-cm
 */
@Service(value = "JdStationApplyService")
public class JdStationApplyServiceImpl extends BaseServiceImpl<JdStationApply> implements JdStationApplyService {

    private final JdStationApplyMapper jdStationApplyMapper;

    public JdStationApplyServiceImpl(
            @Qualifier("jdStationApplyMapper") JdStationApplyMapper jdStationApplyMapper
    ) {
        this.jdStationApplyMapper = jdStationApplyMapper;
    }

    @Override
    @Resource(name = "jdStationApplyMapper")
    public void setBaseMapper(LcBaseMapper<JdStationApply, Serializable> baseMapper) {
        this.baseMapper = baseMapper;
    }

    @Override
    public int applyStation(Integer stationId, Integer userId, Date applyTime) {
        JdStationApply apply = new JdStationApply();
        apply.setStationId(stationId);
        apply.setUserId(userId);
        apply.setApplyTime(applyTime);
        apply.setCreateTime(DateUtils.getToday());
        return jdStationApplyMapper.insert(apply);
    }
}
